<?php echo $this->Html->script(array('users.view','actions','crumbs'),$options = array('allowCache'=>false,'safe'=>false,'inline'=>false));?>
<?php echo $this->Html->css(array('events.view','provider.index.images','events.lists','lastminute-left','search-left','form','actions'),null,array('inline'=>false));?>


<?php $this->Html->addCrumb('Events',array('controller'=>'events','action'=>'index'))?>
<?php $this->Html->addCrumb($event['Event']['name'],array('controller'=>'events','action'=>'view',$event['Event']['id']))?>

<div id="crumbs" class="corners">
	<?php echo $this->Html->getCrumbs(Configure::read('Config.crumbs'),'Home')?>
</div>

<div class="content">
	<div class="left-column">
		<?php echo $this->Yachts->search_form_left();?>		
		<div class="clr"></div>	
		<?php echo $this->Yachts->lastminute(2);?>
		<div class="clr"></div>	
	</div>
	
	
	<div class="middle-column main-column">
		<div class="box corners events">		
			<h2><?php echo $event['Event']['name']?></h2>
			<p><?php echo $event['Event']['small_content']; ?></p>
			<p><?php echo $event['Event']['content']; ?></p>
			<div class="events-info  corners-4">
				<span class="autor">
					<?php echo $this->Html->link($this->Html->image(HOST.'/icon_user.png',array('title'=>$event['User']['first_name'].__(' Profile',true))),array('controller'=>'users','action'=>'view',$event['User']['id']),array('escape'=>false))?>
					<?php echo $this->Html->link($this->Html->image(HOST.'/icon_friend_add.png',array('title'=>__('Add As Friend',true))),array('controller'=>'friends','action'=>'add',$event['User']['id']),array('escape'=>false))?>
					<?php echo $this->Html->link($this->Html->image(HOST.'/icon_message_add.png',array('title'=>__('Create Message',true))),array('controller'=>'messages','action'=>'add',$event['User']['id']),array('escape'=>false))?>
					<?php echo $event['User']['first_name']?>
				</span>
				<span class="comments">
					<?php echo count($event['Post']).$this->Html->image(HOST.'/icon_comments.png',array('title'=>__('Comments total',true)))?>
					
				</span>
				<span class="created">
					<?php echo $this->Html->link($this->Html->image(HOST.'/icon_join_event.png',array('title'=>__('Join to Event',true))),array('controller'=>'events','action'=>'join',$event['Event']['id']),array('escape'=>false))?>
					<?php echo $this->Html->image(HOST.'/icon_calendar.png',array('title'=>__('Created',true))).$event['Event']['created']?>
				</span>
				<div class="clr"></div>
			</div>
			<div class="clr"></div>
		</div>
		
		<?php if (!empty($event['Upload'])):?>
		<div class="box corners related" style="margin-top: 10px;">
			<h3><?php __('Related Uploads');?></h3>
		
			<table cellpadding = "0" cellspacing = "0">
			<tr>
				<th><?php __('Id'); ?></th>
				<th><?php __('Name'); ?></th>
				<th><?php __('Type'); ?></th>
				<th><?php __('Size'); ?></th>
				<th><?php __('Created'); ?></th>
				<th><?php __('Modified'); ?></th>
				<th class="actions"><?php __('Actions');?></th>
			</tr>
			<?php
				$i = 0;
				foreach ($event['Upload'] as $upload):
					$class = null;
					if ($i++ % 2 == 0) {
						$class = ' class="altrow"';
					}
				?>
				<tr<?php echo $class;?>>
					<td><?php echo $upload['id'];?></td>
					<td><?php echo $upload['name'];?></td>
					<td><?php echo $upload['type'];?></td>
					<td><?php echo $upload['size'];?></td>
					<td><?php echo $upload['created'];?></td>
					<td><?php echo $upload['modified'];?></td>
					<td class="actions">
						<?php echo $this->Html->link(__('View', true), array('controller' => 'uploads', 'action' => 'view', $upload['id'])); ?>
						<?php echo $this->Html->link(__('Edit', true), array('controller' => 'uploads', 'action' => 'edit', $upload['id'])); ?>
						<?php echo $this->Html->link(__('Delete', true), array('controller' => 'uploads', 'action' => 'delete', $upload['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $upload['id'])); ?>
					</td>
				</tr>
			<?php endforeach; ?>
			</table>		
		</div>
		<?php endif; ?>
		
		<div class="box corners related" style="margin-top: 10px;">		
			<h2><?php echo __('Posts',true)?></h2>	
			<?php if (!empty($event['Post'])){?>
			<table cellpadding = "0" cellspacing = "0" class="index">
			<?php
				$i = 0;
				foreach ($event['Post'] as $post){
					if($post['status']){
					$class = null;
					if ($i++ % 2 == 0) {
						$class = ' class="altrow"';
					}
				?>
				<tr<?php //echo $class;?>>
					<td width="100%" class="posts">
						<p class="post-content"><?php echo $post['content'];?></p>

						<div class="posts-info corners-4">
							<span class="autor">
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_user.png',array('title'=>$post['User']['first_name'].__(' Profile',true))),array('controller'=>'users','action'=>'view',$post['User']['id']),array('escape'=>false))?>
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_friend_add.png',array('title'=>__('Add As Friend',true))),array('controller'=>'friends','action'=>'add',$post['User']['id']),array('escape'=>false))?>
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_message_add.png',array('title'=>__('Create Message',true))),array('controller'=>'messages','action'=>'add',$post['User']['id']),array('escape'=>false))?>
								<?php echo $post['User']['first_name']?>				
							</span>
							
							<?php if($session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'admin' || $session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'users' && $session->read('Auth.User.id') ==  $event['Event']['user_id']){?>
							<span class="comments">
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_comments_deactivate.png',array('title'=>__('Comments Deactivate',true))), array('controller' => 'posts', 'action' => 'active', $post['id']),array('escape'=>false));?>
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_comments_delete.png',array('title'=>__('Delete Comment',true))),array('controller' => 'posts', 'action' => 'delete', $post['id']),array('escape'=>false))?>
							</span>
							<?php }?>
							
							<span class="created" style="width: 20%"><?php echo $this->Html->image(HOST.'/icon_calendar.png',array('title'=>__('Created',true))).$post['created']?></span>
							<div class="clr"></div>
						</div>
						<div class="clr"></div>
						<?php //echo $this->Html->link(__('Edit', true), array('controller' => 'posts', 'action' => 'edit', $post['id'])); ?>
					</td>				
				</tr>
			<?php }}; ?>
			</table>
			<?php }; ?>
		</div>
		
		<div class="box corners" style="margin-top: 10px;">		
		
			<?php echo $this->Form->create('Post',array('url'=>array('controller'=>'posts','action'=>'add')));?>
				<h2><?php __('Add Post'); ?></h2>
				<?php
					echo $this->Form->hidden('user_id',array('value'=>$user_id));
					echo $this->Form->hidden('Event',array('value'=>$event['Event']['id']));
					echo $this->Form->input('content',array('label'=>false));
				?>
			
			<?php echo $this->Form->end(__('Submit', true));?>
		
		
		</div>

		<?php if($session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'admin' || $session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'users' && $session->read('Auth.User.id') == $event['Event']['user_id']){?>
		<div class="box corners related" style="margin-top: 10px;">		
			<h2><?php echo __('Deactivated Posts',true)?></h2>	
			<?php if (!empty($event['Post'])){?>
			<table cellpadding = "0" cellspacing = "0" class="index">
			<?php
				$i = 0;
				foreach ($event['Post'] as $post){
					if(!$post['status'] && $session->read('Auth.User.id') ==  $event['Event']['user_id']){
					$class = null;
					if ($i++ % 2 == 0) {
						$class = ' class="altrow"';
					}
				?>
				<tr<?php //echo $class;?>>
					<td width="100%" class="posts">
						<p class="post-content"><?php echo $post['content'];?></p>

						<div class="posts-info corners-4">
							<span class="autor">
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_user.png',array('title'=>$post['User']['first_name'].__(' Profile',true))),array('controller'=>'users','action'=>'view',$post['User']['id']),array('escape'=>false))?>
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_friend_add.png',array('title'=>__('Add As Friend',true))),array('controller'=>'friends','action'=>'add',$post['User']['id']),array('escape'=>false))?>
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_message_add.png',array('title'=>__('Create Message',true))),array('controller'=>'messages','action'=>'add',$post['User']['id']),array('escape'=>false))?>
								<?php echo $post['User']['first_name']?>				
							</span>
							
							<?php if($session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'admin' || $session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'users' && $session->read('Auth.User.id') ==  $event['Event']['user_id']){?>
							<span class="comments">
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_comments_activate.png',array('title'=>__('Activate Comment',true))), array('controller' => 'posts', 'action' => 'active', $post['id']),array('escape'=>false));?>
								<?php echo $this->Html->link($this->Html->image(HOST.'/icon_comments_delete.png',array('title'=>__('Delete Comment',true))),array('controller' => 'posts', 'action' => 'delete', $post['id']),array('escape'=>false))?>
							</span>
							<?php }?>
							
							<span class="created" style="width: 20%"><?php echo $this->Html->image(HOST.'/icon_calendar.png',array('title'=>__('Created',true))).$post['created']?></span>
							<div class="clr"></div>
						</div>
						<div class="clr"></div>
											
																		
					</td>				
				</tr>
			<?php }}; ?>
			</table>
			<?php }; ?>
		</div>
		<?php }?>
		
	</div>
	
	<div class="right-column">
		<?php echo $this->element('user_main_left_menu')?>		
		
	</div>
</div>


<?php if($session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'admin' || $session->check('Auth.User.id') && $this->Session->read('Auth.User.group') == 'manag'){?>
	<div class="actions main_actions">
		<h3><?php __('Actions'); ?></h3>
		<ul>
			<li><?php echo $this->Html->link(__('Edit Event', true), array('action' => 'edit', $event['Event']['id'])); ?> </li>
			<li><?php echo $this->Html->link(__('Delete Event', true), array('action' => 'delete', $event['Event']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $event['Event']['id'])); ?> </li>
			<li><?php echo $this->Html->link(__('List Events', true), array('action' => 'index')); ?> </li>
			<li><?php echo $this->Html->link(__('New Event', true), array('action' => 'add')); ?> </li>
			<li><?php echo $this->Html->link(__('List Posts', true), array('controller' => 'posts', 'action' => 'index')); ?> </li>
			<li><?php echo $this->Html->link(__('New Post', true), array('controller' => 'posts', 'action' => 'add')); ?> </li>
			<li><?php echo $this->Html->link(__('New Upload', true), array('controller' => 'uploads', 'action' => 'add')); ?> </li>
		</ul>
	</div>
<?php }?>	

<div class="clr"></div>